﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class SelfScore : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {
        ((Label)Page.Master.FindControl("ErrorLabel")).Text = "";
    }
    protected void ObjectDataSource_SS_DataBinding(object sender, EventArgs e)
    {
       
    }
    protected void ObjectDataSource_SS_Selecting(object sender, ObjectDataSourceSelectingEventArgs e)
    {
        
    }

    protected string GetDptNameById(object DptId)
    {
        DepartmentDb dptDb = new DepartmentDb();

        return (string)dptDb.GetDepartmentNameById((int)DptId);
    }

    protected void ObjectDataSource_SS_Load(object sender, EventArgs e)
    {
        //get serial num from session
        int staffSerialNum = ((KaohePage)Page).MainLogic.GetCurSerialNum();
        ObjectDataSource_SS.SelectParameters.Clear();
        ObjectDataSource_SS.SelectParameters.Add("SerailNum", staffSerialNum.ToString());
    }
    protected void DetailsView_SS_DataBound(object sender, EventArgs e)
    {

    }
    protected void ObjectDataSource_SS_Selected(object sender, ObjectDataSourceStatusEventArgs e)
    {

    }

    protected void DetailsView_SS_ItemUpdating(object sender, DetailsViewUpdateEventArgs e)
    {
        if (Utility.HasNullValue(e.NewValues))
        {
            ((Label)Page.Master.FindControl("ErrorLabel")).Text = "输入不能为空！";
            e.Cancel = true;
            return;
        }

        string score = e.NewValues["SelfScore"].ToString();
        bool valid = true;
        int result;
        if (!int.TryParse(score, out result) || result < 0 || result > 100)
        {
            valid = false;
        }

        // Set the error message label.
        if (!valid)
        {
            ((Label)Page.Master.FindControl("ErrorLabel")).Text = "请确定评分在0~100之间。";
            e.Cancel = true;
        }
        else
            ((Label)Page.Master.FindControl("ErrorLabel")).Text = "";
    }
}
